package org.qiyu.live.api.controller;

import jakarta.annotation.Resource;
import org.qiyu.live.api.service.IBankService;
import org.qiyu.live.api.vo.req.PayProductReqVO;
import org.qiyu.live.common.interfaces.vo.WebResponseVO;
import org.qiyu.live.web.starter.error.ErrorAssert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.qiyu.live.web.starter.error.QiYuBaseErrorEnum.BANK_PRODUCTS_ERROR;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-11-04
 * Time: 23:01
 */
@RestController
@RequestMapping("/bank")
public class BankController {
    @Resource
    private IBankService bankService;

    /**
     * 查询所有的商品
     *
     * @param type 商品类型
     * @return 返回所有商品
     */
    @PostMapping("/products")
    public WebResponseVO products(Integer type) {
        ErrorAssert.isNotNull(type, BANK_PRODUCTS_ERROR);
        return WebResponseVO.success(bankService.products(type));
    }

    @PostMapping("/payProduct")
    public WebResponseVO payProduct(PayProductReqVO payProductReqVO) {
        return WebResponseVO.success(bankService.payProduct(payProductReqVO));
    }
}